package review;

import java.util.Scanner;

//软件测试
public class OrderManager {

	public static void main(String[] args) {

		System.out.println("吃货联盟订餐系统");
		String prodnam[] = { "红烧带鱼", "鱼香肉丝", "时令鲜蔬" };// 菜品数组
		double prices[] = { 38, 20, 10 };// 菜品价格
		int praise[] = new int[3];// 点赞数

		String[] ordername = new String[6];// 订餐人数
		ordername[0] = "王小明";
		ordername[1] = "王大祥";

		String[] dishmsg = new String[6];// 选择的菜品
		dishmsg[0] = prodnam[0];
		dishmsg[1] = prodnam[1];

		int ordernum[] = new int[6];// 订菜的数量
		ordernum[0] = 1;
		ordernum[1] = 2;

		int times[] = new int[6];// 时间
		times[0] = 12;
		times[0] = 18;

		String gps[] = new String[6];// 地址
		gps[0] = "天成路207号";
		gps[1] = "天成路207号";

		int zt[] = new int[6];// 状态
		zt[0] = 0;
		zt[1] = 1;

		double jg[] = new double[6];// 价格
		jg[0] = 76;
		jg[0] = 45;

		Scanner in = new Scanner(System.in);
		int choice = 0;
		while (true) {
			System.out.println("*************************");
			System.out.println("1.我要订餐");
			System.out.println("2.查看餐袋");
			System.out.println("3.签收订单");
			System.out.println("4.删除订单");
			System.out.println("5.我要点赞");
			System.out.println("6.退出系统");
			System.out.println("*************************");
			choice = in.nextInt();
			switch (choice) {
			case 1: // 选择菜品给客户选择
				for (int i = 0; i < prodnam.length; i++) {
					System.out.println((i + 1) + " " + prodnam[i] + " " + prices[i] + " " + praise[i]);
				}
				// 开始选择
				int ch = 0;
				while (true) {
					ch = in.nextInt();
					if (ch >= 1 && ch <= 3)
						break;
				}
				System.out.println("顾客姓名：");
				String xingming = in.next();
				System.out.println("要几份：");
				int fenshu = in.nextInt();
				System.out.println("送餐时间：");
				int shijian = in.nextInt();
				System.out.println("送餐地址：");
				String adr = in.next();
				// 在餐袋中找到位置放置新的订单
				for (int i = 0; i < ordernum.length; i++) {
					if (ordername[i] == null) {
						ordername[i] = xingming;
						dishmsg[i] = prodnam[ch - 1];
						ordernum[i] = fenshu;
						times[i] = shijian;
						gps[i] = adr;
						double money = prices[ch - 1] * fenshu;
						money = money >= 50 ? money : money + 5;
						jg[i] = money;
						break;

					}
				}

				break;
			case 2:
				System.out.println("***********************");
				System.out.println("餐袋信息：");
				System.out.println("序号   姓名   餐品信息\t数量\t送餐时间\t地址\t金额   状态");

				for (int i = 0; i < ordername.length; i++) {
					if (ordername[i] == null)
						break;
					System.out.println((i + 1) + ordername[i] + "\t" + dishmsg[i] + "\t" + ordernum[i] + "\t" + times[i]
							+ "\t" + gps[i] + "\t" + jg[i] + "\t" + (zt[i] == 1 ? "已完成" : "已预订"));
					break;
				}
			case 3:
				System.out.println("***********************");
				System.out.println("订单签收：");
				boolean a = false;
				System.out.println("请选择需要签收的订单:");
				int qs = in.nextInt();// 签收的订单序号
				for (int i = 0; i < ordername.length; i++) {
					if (ordername[i] != null && qs == i + 1 && ordernum[i] == 0) {
						ordernum[i] = 1;
						a = true;
						System.out.println("订单签收成功");
						break;
					} else if (ordername[i] != null && qs == i + 1 && ordernum[i] == 1) {
						System.out.println("此订单已签收 无需再次签收");
						a = true;
						break;
					}
					if (a == false) {
						System.out.println("您选择的订单不存在");
					}
					System.out.println("返回上一层请按0");
					int fh1 = in.nextInt();// fh1返回
					if (fh1 == 0)
						break;
				}

			}

		}
	}
}